package cn.tedu.imop.basic.controller;

import cn.tedu.imop.api.model.RestResult;
import cn.tedu.imop.api.model.RestResultUtils;
import cn.tedu.imop.basic.entity.Business;
import cn.tedu.imop.basic.entity.BusinessCategory;
import cn.tedu.imop.basic.service.BusinessCategoryService;
import cn.tedu.imop.basic.service.BusinessService;
import cn.tedu.imop.common.constants.Constants;
import cn.tedu.imop.common.pojo.PageData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags="商家信息")
@RestController
@RequestMapping(Constants.CONTROLLER_API_VERSION +"/business")
public class BusinessController {
    private final BusinessService businessService;
    public BusinessController(BusinessService businessService) {
        this.businessService = businessService;
    }
    @ApiOperation("商家入驻")
    @PostMapping
    public RestResult<Business> createBusiness(Business business) {
        businessService.createBusiness(business);
        return RestResultUtils.success();
    }
    @ApiOperation("商家列表")
    @GetMapping
    public RestResult<PageData<Business>> getBusinessList(Business business) {
        return RestResultUtils.success(businessService.getBusinessList(business));
    }
}
